package ue.client.entities;

import java.util.ArrayList;

import ue.client.core.Vector2i;

public abstract class StaticEntity {
	
	public static ArrayList<StaticEntity> staticEntities = new ArrayList<StaticEntity>();
	
	private static int lastID = 0;
	
	protected final int ID;
	
	protected Vector2i pos, size;
	
	public StaticEntity(Vector2i pos, Vector2i size) {
		this.pos = pos;
		this.size = size;
		
		ID = lastID++;
	}

	public Vector2i getPos() {
		return pos;
	}

	public void setPos(Vector2i pos) {
		this.pos = pos;
	}
	
	public Vector2i getSize() {
		return size;
	}

	public void setSize(Vector2i size) {
		this.size = size;
	}

	public int getID() {
		return ID;
	}
	
	
	//STATIC METHODS
	public static int addStaticEntity(StaticEntity entity) {
		StaticEntity tmp = getStaticEntity(entity.getID());
		if(tmp == null) {
			staticEntities.add(entity);
			return entity.getID();
		}
		return tmp.getID();
	}
	
	public static void removeStaticEntity(int ID) {
		for (int i = 0; i < staticEntities.size(); i++) {
			if (staticEntities.get(i).getID() == ID) {
				staticEntities.remove(i);
				return;
			}
		}
		return;
	}
	
	public static StaticEntity getStaticEntity(int ID) {
		for (int i = 0; i < staticEntities.size(); i++) {
			if (staticEntities.get(i).getID() == ID)
				return staticEntities.get(i);
		}
		return null;
	}
}
